home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / PROLOG.S < prev    next >
Text File  |  1989-04-27  |  2KB  |  58 lines

  1. ******************************************************************************
  2. * prolog.s 3.1 11/12/84 
  3. *
  4. *        68HC11 CROSS C COMPILER RUN-TIME LIBRARY
  5. *
  6. *           (c) Copyright 1984, Motorola, Inc.
  7. *
  8. *  FUNCTION NAME:    .prolog
  9. *
  10. *  ACTION:        Allocate the stack frame for a C function.  
  11. *            Initialize the frame pointer, X.
  12. *
  13. *  REGISTERS AND STACK:
  14. *
  15. *  ON ENTRY:    X:    Old FP (frame pointer)
  16. *
  17. *        STACK:      Incoming Arguments
  18. *            Return Address to C caller
  19. *        SP:    Return Address to C callee (Ptr to in-line constants):
  20. *                fdb    frame_size
  21. *                fdb    fp_offset (250 - SIZEOF(incoming args))
  22. *
  23. *  ON EXIT:    X:    New FP (256 bytes below furthest argument)
  24. *
  25. *        STACK:    Incoming Arguments
  26. *            Return Address to C caller (2 bytes)
  27. *            Old FP (2 bytes)
  28. *            New FP-256 (2 bytes)
  29. *        SP:    Local Variables (frame_size bytes)
  30. *
  31. *  NOTES: New FP may be above or below the SP, depending upon the size
  32. *      of the frame.
  33. *
  34. *        Returns to first instruction following the in-line constants.
  35. *
  36. ******************************************************************************
  37.     psct
  38.     xdef    .prolog
  39. .prolog:
  40.     puly        ptr to in-line args
  41.     pshx        save old FP
  42.     pshx        space for new FP-256
  43.     tsx        copy SP to X
  44.     pshx        ...and D
  45.     pula
  46.     pulb
  47.     subd    2,%y    new FP = old SP - fpoffset
  48.     deca        ...- 256
  49.     std    0,%x    store FP-256
  50.     inca        restore new FP
  51.     xgdx        FP in X.  SP in D.
  52.     subd    0,%y    new SP = old SP - framesize
  53.     xgdx        FP is temporarily undone...
  54.     txs        SP done
  55.     xgdx        FP restored.
  56.     jmp    4,%y    return.
  57.     end
  58.